#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
ll a[N], b[N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, m, k; cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    ll mx = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) break;
        ll l = 0, r = m + 1;
        while (l + 1 != r) {
            ll mid = (l + r) / 2;
            if (b[mid] <= k - a[i]) l = mid;
            else r = mid;
        }
        mx = max(mx, i + l);
    }
    cout << mx << '\n';
    return 0;
}